/* Create a lattice system */

import acm.program.*;
import acm.graphics.*;

public class Lattice extends GraphicsProgram {
	/* Vertical line number */
	private static final double VERTICALLINES = 24;

	/* Horizontal line number */
	private static final double HORIZONTALLINES = 24;
	
	/* Vertical line length */
	private static final double VERTICALLENGTH = 300;
	
	/* Horizontal line length */
	private static final double HORIZONTALLENGTH = 300;
	
	/* Vertical line seperation */
	private static final double VERTICALSEPERATION = HORIZONTALLENGTH / VERTICALLINES;
	
	/* Horizontal line seperation */
	private static final double HORIZONTALSEPERATION = VERTICALLENGTH / HORIZONTALLINES;
	

	
	public void run() {
		double x0 = 10.0; 
		double y0 = 10.0; 
		for(int i = 0; i < HORIZONTALLINES; i++) {
			add(drawHorizontalLine(x0,y0,i) );
		}
		for(int i = 0; i < VERTICALLINES; i++) {
			add(drawVerticalLines(x0,y0,i) );
		}
	}
	
	private GLine drawHorizontalLine(double x0, double y0, int i) {
		/* starting point, x0 doesn't change */
		y0 = y0 + i * HORIZONTALSEPERATION;

		/* end point */
		double x1 = x0 + HORIZONTALLENGTH;
		double y1 = y0;
		
		GLine hLine = new GLine(x0, y0, x1, y1);
		return hLine;
	}

	private GLine drawVerticalLines(double x0, double y0, int i) {
		/* starting point, y0 doesn't change */
		x0 = x0 + i * VERTICALSEPERATION;

		/* end point */
		double x1 = x0;
		double y1 = y0 + VERTICALLENGTH;
		
		GLine vLine = new GLine(x0, y0, x1, y1);
		return vLine;
	}
}
